package com.ruizhong.centercontroll.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruizhong.centercontroll.dao.TProgramMapper;
import com.ruizhong.centercontroll.entity.TProgram;
import com.ruizhong.centercontroll.service.TProgramService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TProgramServiceImpl extends ServiceImpl<TProgramMapper, TProgram> implements TProgramService {
    @Override
    public synchronized void submitNewProgram(TProgram tProgram) {
        save(tProgram);
    }

    @Override
    public synchronized void updateProgramInfo(TProgram tProgram) {
        updateById(tProgram);
    }

    @Override
    public List<TProgram> getAllProgramList() {
        return list();
    }

    @Override
    public TProgram getProgramDetailById(Integer id) {
        TProgram tProgram = lambdaQuery()
                .eq(TProgram::getId, id)
                .one();
        return tProgram;
    }

    @Override
    public void deleteProgramById(Integer id) {
        removeById(id);
    }

    @Override
    public List<TProgram> getProgramBySQId(Integer id) {
        List<TProgram> list = lambdaQuery()
                .eq(TProgram::getSqId, id)
                .list();
        return list;
    }
}
